package com.godyao.mall.goods.repository;


import com.godyao.mall.core.model.goods.Goods;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

/**
 * @author godyao
 * @date 2022/3/31
 */
@Repository
public interface GoodsRepository extends JpaRepository<Goods, Long> {
    //@Query("select g from Goods g where g.goodsName like concat('%', ?1, '%') and g.goodsTitle = ?2")
    //Page<Goods> findPagedGoods(String goodsName, String goodsTitle, Pageable pageable);

    /**
     * 动态条件分页查找
     * @param spec
     * @param pageable
     * @return
     */
    Page<Goods> findAll(Specification<Goods> spec, Pageable pageable);
    /**
     * 根据商品id查找商品信息
     * @param goodsId
     * @return
     */
    Goods findGoodsById(Long goodsId);
}
